package com.newgoldcurrency.activities;

import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.newgoldcurrency.R;
import com.newgoldcurrency.databinding.ActivityNameBinding;

public class NameActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        com.newgoldcurrency.databinding.ActivityNameBinding binding = ActivityNameBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        binding.inputNameBack.setOnClickListener(view -> finish());
        JsonObject jo = JsonParser.parseString(getIntent().getStringExtra("data")).getAsJsonObject();
        binding.nameFirstNameEn.setText(getString(R.string.first_name_,jo.get("english_first_name").getAsString()));
        binding.nameFirstNameDoc.setText(getString(R.string.first_name_,jo.get("documentation_first_name").getAsString()));
        String el = jo.get("english_last_name").getAsString();
        if (!el.equals("")){
            binding.englishLastNameEn.setVisibility(View.VISIBLE);
            binding.englishLastNameEn.setText(getString(R.string.last_name_,el));
        }
        String el_doc=jo.get("documentation_last_name").getAsString();
        if (!el_doc.equals("")){
            binding.englishLastNameDoc.setVisibility(View.VISIBLE);
            binding.englishLastNameDoc.setText(getString(R.string.last_name_,el_doc));
        }
        String mid_en=jo.get("english_middle_name").getAsString();
        if (!mid_en.equals("")){
            binding.nameMiddleNameEn.setVisibility(View.VISIBLE);
            binding.nameMiddleNameEn.setText(getString(R.string.middle_name_,mid_en));
        }
        String mid_doc=jo.get("documentation_middle_name").getAsString();
        if (!mid_doc.equals("")){
            binding.nameMiddleNameDoc.setVisibility(View.VISIBLE);
            binding.nameMiddleNameDoc.setText(getString(R.string.middle_name_,mid_doc));
        }
        String maid_en=jo.get("english_maiden_name").getAsString();
        if (!maid_en.equals("")){
            binding.nameMaidenNameEn.setVisibility(View.VISIBLE);
            binding.nameMaidenNameEn.setText(getString(R.string.maiden_name_,maid_en));
        }
        String maid_doc=jo.get("documentation_maiden_name").getAsString();
        if (!maid_doc.equals("")){
            binding.nameMaidenNameDoc.setVisibility(View.VISIBLE);
            binding.nameMaidenNameDoc.setText(getString(R.string.maiden_name_,maid_doc));
        }
    }
}